package util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 日志工具类
 * Created by Lenovo
 * DATA:2023/10/19
 **/
public class LogUtils {
    public static void info(String msg,Object... args){
        print(msg,"INFO",args);
    }
    public static void error(String msg,Object... args){
        print(msg,"ERROR",args);
    }

    private static void print(String msg,String level,Object... args){
        if(args!=null&& args.length>0){
          msg=String.format(msg.replace("{}","%s"),args);
        }
        String name = Thread.currentThread().getName();
        System.out.println(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))+"\t"+name+"\t"+level+"\t"+msg);
    }
}
